<!DOCTYPE>
<html xmlns="https://www.thymeleaf.org/">
<head>
<meta charset="UTF-8">
<title>SpringDataJPA-sample</title>
<!-- 新 Bootstrap 核心 CSS 文件 -->
<link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="../../js/highlight/styles/darkula.css"/>
</head>
<body>

<div class="container">
   <div class="row">
      <div class="col-md-12">
      	<pre>
      		<code style="java">
package com.demo.controller_admin;

import java.util.List;
import javax.annotation.Resource;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.demo.entity.Article;
import com.demo.entity.ResponseResult;
import com.demo.service_admin.impl.ArticleServiceImpl;


@Controller("adminArticleController")
@RequestMapping(value = "/${site.adminUrlPrefix}/article")
public class ArticleController extends BaseController {
	
	@Resource(name="adminArticleService")
	ArticleServiceImpl articleService;

	@GetMapping(value = "list")
	public String list() {
		return adminTemplatePrefix + "/article_list";
	}
	
	@GetMapping(value = "list_json")
	public @ResponseBody ResponseResult<List<Article>> list_json(Integer page, Article article) {
		Page<Article> data = articleService.findAll(article, getPageable(page));
		return new ResponseResult<List<Article>>(data.getTotalElements(), data.getContent());
	}

	@GetMapping(value = "add")
	public String add(Long id, Model model) {
		if(id!=null) {
			model.addAttribute("vo", articleService.findById(id));
		}
		return adminTemplatePrefix + "/article_add";
	}
	
	@PostMapping(value = "save")
	public String save(Article article) {
		articleService.save(article);
		return "redirect:/admin/article/list";
	}
	
	@SuppressWarnings("rawtypes")
	@PostMapping(value = "isShow")
	public @ResponseBody ResponseResult isShow(Long id, String isShow) {
		int result = articleService.isShow(id, isShow);
		return ResponseResult.getResponseResult(result);
	}
	
}
		</code>
      	</pre>
      </div>      
   </div>
</div>

<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>

<script src="../../js/highlight/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</body>
</html>